package budget;
import model.Model;

public class Service extends Model{
	
	public Service(long id, ServiceType serviceType, String name, double cost,boolean onlyOne,boolean perPerson,boolean atDay){
		super(id);
		this.serviceType = serviceType;
		this.atDay=atDay;
		this.perPerson=perPerson;
		this.setCost(cost);
		this.name = name;
		this.onlyOne=onlyOne;
	}
	public Service(ServiceType serviceType, String name, double cost) {
		this(Model.NO_ID,serviceType, name, cost,false,false,false);	
	}
	public Service(ServiceType serviceType, String name, double cost,boolean onlyOne,boolean perPerson,boolean atDay) {
		this(Model.NO_ID,serviceType, name, cost,onlyOne,perPerson,atDay);	
	}
	
	public ServiceType getServiceType() {
		return serviceType;
	}
	public void setServiceType(ServiceType serviceType) {
		this.serviceType = serviceType;
	}
	public double getCost() {
		return cost;
	}
	public void setCost(double cost) {
		this.cost = Math.rint( (cost)*100)/100;;
	}
	
	public boolean contains(String filter) {
		String string = serviceType +" "+name + " "+cost;
		if(string.contains(filter))
			return true;
		return false;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public boolean isOnlyOne(){
		switch(this.serviceType){
			case ARTIST:{return false;}
			case COURSE:{return false;}
			case EVENT_PREPARATION:{return true;}
			case MENU:{return true;}
			case FLOWERS:{return true;}
			default: {return onlyOne;}
		}
	}
	
	public boolean isAtDay(){
		switch(this.serviceType){
		case ARTIST:{return true;}
		case COURSE:{return true;}
		case EVENT_PREPARATION:{return true;}
		case MENU:{return true;}
		case FLOWERS:{return atDay;}
		default: {return atDay;}
		}
	}
	
	public boolean isPerPerson(){
		switch(this.serviceType){
			case ARTIST:{return false;}
			case COURSE:{return true;}
			case EVENT_PREPARATION:{return true;}
			case MENU:{return true;}
			case FLOWERS:{return false;}
			default: {return perPerson;}
		}
	}
	
	public static Service clone(Service serv){
		return new Service(serv.getId(),serv.serviceType, serv.name, serv.cost,serv.onlyOne,serv.perPerson,serv.atDay);
	}
	
	private boolean atDay=false;
	private boolean perPerson=false;
	private boolean onlyOne=false;
	public enum ServiceType{
	FLOWERS,
	COURSE,
	MENU,
	ARTIST,
	EVENT_PREPARATION,
	OTHER}
	private ServiceType serviceType;
	private String name;
	private double cost;
}
